package com.hetang.domain.common;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.hetang.domain.enums.ResponseCodeEnum;

/**
 * Created by Duo Duo on 2016/12/26.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MsgResponse<T>{

    private Integer status;

    private String message;

    private Integer recordsTotal;

    private T data;

    public MsgResponse(){}

    public MsgResponse(int status){
        this.status = status;
    }

    public MsgResponse(ResponseCodeEnum responseCodeEnum){
        this.status = responseCodeEnum.getCode();
        this.message = responseCodeEnum.getValue();
    }

    public MsgResponse(ResponseCodeEnum responseCodeEnum, String message){
        this.status = responseCodeEnum.getCode();
        this.message = message;
    }

    public MsgResponse(ResponseCodeEnum responseCodeEnum, T data){
        this.status = responseCodeEnum.getCode();
        this.message = responseCodeEnum.getValue();
        this.data = data;
    }

    public MsgResponse(ResponseCodeEnum responseCodeEnum,T data,Integer pageCount){
        this.status = responseCodeEnum.getCode();
        this.message = responseCodeEnum.getValue();
        this.data = data;
        this.recordsTotal = pageCount;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getRecordsTotal() {
        return recordsTotal;
    }

    public void setRecordsTotal(Integer recordsTotal) {
        this.recordsTotal = recordsTotal;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "MsgResponse{" +
                "status=" + status +
                ", data=" + data +
                ", message='" + message + '\'' +
                ", recordsTotal=" + recordsTotal +
                '}';
    }
}
